namespace IAM.Interface.Model
{
    using IAM.Interface.Model.Interface;
    using System;
    using System.Reflection;
    using System.Text;

    public class ACMMode : AbstractConvertObject, IConvertXml
    {
        private Dimensions _dimensionList = null;
        private bool _multisection = false;
        private ACSections _sectionList = null;

        public override object ConvertToObject()
        {
            if (this.CurrentXmlNode.Attributes["MultiSection"].InnerText.ToLower() == "true")
            {
                this.MultiSection = true;
            }
            else
            {
                this.MultiSection = false;
            }
            this.SectionList = new ACSections();
            this.SectionList.CurrentXmlNode = this.CurrentXmlNode.SelectSingleNode("ACSections");
            this.SectionList = (ACSections) this.SectionList.ConvertToObject();
            this.DimensionList = new Dimensions();
            this.DimensionList.CurrentXmlNode = this.CurrentXmlNode.SelectSingleNode("Dimensions");
            this.DimensionList = (Dimensions) this.DimensionList.ConvertToObject();
            return this;
        }

        public override bool Equals(object obj)
        {
            ACMMode ai = null;
            try
            {
                ai = (ACMMode) obj;
            }
            catch
            {
                return false;
            }
            bool result = true;
            if (this.MultiSection != ai.MultiSection)
            {
                result = false;
            }
            else if (!this.SectionList.Equals(ai.SectionList))
            {
                result = false;
            }
            else if (!this.DimensionList.Equals(ai.DimensionList))
            {
                result = false;
            }
            return result;
        }

        public override int GetHashCode()
        {
            int result = 1;
            foreach (PropertyInfo onofpi in base.GetType().GetProperties())
            {
                result += onofpi.GetHashCode();
            }
            return result;
        }

        public Dimensions DimensionList
        {
            get
            {
                return this._dimensionList;
            }
            set
            {
                this._dimensionList = value;
            }
        }

        public bool MultiSection
        {
            get
            {
                return this._multisection;
            }
            set
            {
                this._multisection = value;
            }
        }

        public ACSections SectionList
        {
            get
            {
                return this._sectionList;
            }
            set
            {
                this._sectionList = value;
            }
        }

        public string XML
        {
            get
            {
                return (this.XMLBoday + this.XMLFinis);
            }
        }

        public string XMLBoday
        {
            get
            {
                StringBuilder _xml = new StringBuilder();
                _xml.Append("<ACMMode");
                _xml.Append(" MultiSection=\"" + this.MultiSection + "\"");
                _xml.Append(" >");
                _xml.Append(this.SectionList.XML);
                _xml.Append(this.DimensionList.XML);
                return _xml.ToString();
            }
        }

        public string XMLFinis
        {
            get
            {
                return "</ACMMode>";
            }
        }
    }
}

